Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instrumentation for Azure Service Bus #1225

Merged
merged 25 commits into from
Apr 6, 2021

Conversation

russcam
Copy link
Contributor

@russcam russcam commented Mar 16, 2021

This PR adds instrumentation for Azure Service Bus when an application is using Microsoft.Azure.ServiceBus 3.0.0+ or Azure.Messaging.ServiceBus 7.0.0+ nuget packages.

Two IDiagnosticListener implementations, one for Microsoft.Azure.ServiceBus and another for Azure.Messaging.ServiceBus, create transactions and spans for received and sent messages:

A new transaction is created when

  • one or more messages are received from a queue or topic subscription.
  • a message is receive deferred from a queue or topic subscription.

A new span is created when there is a current transaction, and when

  • one or more messages are sent to a queue or topic.
  • one or more messages are scheduled to a queue or a topic.

A terrform template file is used to create a resource group, Azure Service Bus namespace resource in the resource group, and set RBAC rules to allow the Service Principal that issues the creation access to the resources. The Service Principal credentials can are sourced from a .credentials.json file in the root of the repository for CI, and from an account authenticated with az for local development. A default location is set within the template, but all variables can be passed using standard Terraform input variable conventions.

Closes #1157

@russcam russcam added enhancement New feature or request v1.9.0 and removed agent-dotnet labels Mar 16, 2021
@russcam
Copy link
Contributor Author

russcam commented Mar 16, 2021

An outstanding item is to set the distributed tracing data for receive/receive deferred messages. Messages are typically retrieved and sent in batches however, where each message may represent its own distributed trace. elastic/apm#122 proposes introducing a links property to capture each. Both Microsoft.Azure.ServiceBus and Azure.Messaging.ServiceBus expose the linked traces.

@apmmachine
Copy link
Contributor

apmmachine commented Mar 16, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #1225 updated

  • Start Time: 2021-03-30T06:23:37.126+0000

  • Duration: 58 min 22 sec

  • Commit: 5afeb85

Test stats 🧪

Test Results
Failed 0
Passed 19155
Skipped 64
Total 19219

Trends 🧪

Image of Build Times

Image of Tests

@russcam
Copy link
Contributor Author

russcam commented Mar 25, 2021

Going to rebase this against master, to pick up #1240 to run tests on CI

Copy link
Contributor

@gregkalapos gregkalapos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a first look, very nice 👍

I added some comments below. On the central config part: I'm not sure it's worth the effort to make the new config runtime changeable right now in this PR - if it turns out to be more work, I think it's totally fine to do it in a follow up - just update the doc in that case.


[float]
[[config-ignore-message-queues]]
==== `IgnoreMessageQueues` (added[1.9])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
==== `IgnoreMessageQueues` (added[1.9])
==== `IgnoreMessageQueues` (added[1.10])

@@ -266,6 +266,8 @@ internal WrappingConfigSnapshot(IConfigSnapshot wrapped, CentralConfigReader cen

public string HostName => _wrapped.HostName;

public IReadOnlyList<WildcardMatcher> IgnoreMessageQueues => _wrapped.IgnoreMessageQueues;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we'll need something like this:

 _centralConfig.IgnoreMessageQueues ?? _wrapped.IgnoreMessageQueues;

_centralConfig.IgnoreMessageQueues doesn't exist yet, that's what we should implement and parse in CentralConfigReader, otherwise it'll only return values from the local config.

@russcam russcam merged commit 63df486 into elastic:master Apr 6, 2021
@russcam russcam added v1.10.0 and removed v1.9.0 labels Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v1.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[META 410] Instrumentation for Azure ServiceBus
3 participants